<?php
include("utils1.php");

 if($_SESSION['siteuserId']=="")
{
	header("location:index.php");
}


main_content("main();");
function main()
{
	 if($_SESSION['languageId']!="")
{
	$languageId=$_SESSION['languageId'];
}
else
{
	$languageId='1';
}

	$siteUserId=$_SESSION['siteuserId'];

	$selSiteurl=mysql_query("select * from adsite_master where siteuserId='".$siteUserId."'");
	
	if(isset($_POST['next']))
	{
	/*---------allow net starts------*/
		if($_POST['allow_network']=='Y')
		{
			$netVal='Y';
		}
		else
		{
			$netVal='N';
		}
	/*---------allow net ends------*/

	/*---------thumb handle starts------*/
		if($_POST['thumbCompHandle']=='Y')
		{
			$thumHamdleVal='Y';
		}
		else
		{
			$thumHamdleVal='N';
		}
	/*---------thumb handle  ends------*/
	/*---------thumbCompAge starts------*/
		if($_POST['thumbCompAge']=='Y')
		{
			$thumbCompAge='Y';
		}
		else
		{
			$thumbCompAge='N';
		}
	/*---------thumbCompAge ends------*/
	/*---------thumbComplOCATION starts------*/

		if($_POST['thumbComplOCATION']=='Y')
		{
			$thumbComplOCATIONVal='Y';
		}
		else
		{
			$thumbComplOCATIONVal='N';
		}
	/*---------thumbComplOCATION ends------*/
	/*---------thumbCompHeadline starts------*/
		if($_POST['thumbCompHeadline']=='Y')
		{
			$thumbCompHeadlineVal='Y';
		}
		else
		{
			$thumbCompHeadlineVal='N';
		}
	/*---------thumbCompHeadline ends------*/
	/*---------thumbCompImage starts------*/
	if($_POST['thumbCompImage']=='Y')
		{
			$thumbCompImageVal='Y';
		}
		else
		{
			$thumbCompImageVal='N';
		}
	/*---------thumbCompImage ends------*/
	/*---------thumbCustomSize starts------*/
	if($_POST['thumbCustomSize']=='Y')
		{
			$thumbCustomSizeVal='Y';
		}
		else
		{
			$thumbCustomSizeVal='N';
		}
	/*---------thumbCustomSize ends------*/
	/*---------thumbCustomSize starts------*/
	if($_POST['thumbCustomSize']=='Y')
		{
			$thumbCustomSizeVal='Y';
		}
		else
		{
			$thumbCustomSizeVal='N';
		}
	/*---------thumbCustomSize ends------*/

	
		$adSiteId         = $_POST['site_id'];
		$adspaceType      = $_POST['adspace_type'];
		$thumbSize        = $_POST['thumbSize'];
		$thumbView        = $_POST['thumbCount'];
		$thumbCustomWidth = $_POST['width'];
		$thumbCustomHeight= $_POST['height'];
		$thumbOrientation = $_POST['alignment'];
		$thumbbgcolor     = $_POST['background_color'];

		$thumbBodyFontSize        = $_POST['description_font_size'];
		$thumbBodyFontType        = $_POST['description_font_type'];
		$thumbBodyFontColor       = $_POST['description_font_color'];
		$thumbBodyAlign           = $_POST['description_align'];
		$thumbBodyAttriItalic     = $_POST['description_italic'];
		$thumbBodyAttriBold       = $_POST['description_bold'];
		$thumbBodyAttriUnderline  = $_POST['description_underline'];
		
		$thHeaderFontSize       = $_POST['title_font_size'];
		$thHeaderFontType       = $_POST['title_font_type'];
		$thHeaderFontColor      = $_POST['title_font_color'];
		$thHeaderAlign          = $_POST['title_align'];
		$thHeaderAttriItalic    = $_POST['title_italic'];
		$thHeaderAttriBold      = $_POST['title_bold'];
		$thHeaderAttriUnderline = $_POST['title_underline'];


	$selpresentVal=mysql_fetch_array(mysql_query("select * from adspace_master where UserId='".$siteUserId."'"));

	//if($selpresentVal['adspaceId']=='')
	//{
	$insertAdMaster="insert into adspace_master set adsiteId='".$_POST['site_id']."', UserId='".$siteUserId."', langId='".$languageId."'";
	//echo $insertAdMaster;
	$exeAdmaster = mysql_query($insertAdMaster);
	$adspaceId = mysql_insert_id();

	$insertThumbDta= "insert into adspace_details set adspaceId='".$adspaceId."', adspaceType='".$adspaceType."', thumbSize='".$thumbSize."', thumbView='".$thumbView."', thumbCustomSize='".$thumbCustomSizeVal."', thumbCustomWidth='".$thumbCustomWidth."', thumbCustomHeight='".$thumbCustomHeight."', thumbOrientation='".$thumbOrientation."', backgroundColor='".$thumbbgcolor."',allowNetwork='".$netVal."'";
	//echo $insertThumbDta.'<br />';

	$exeinsertAd = mysql_query($insertThumbDta);

	if($_REQUEST['insertmode']=='insertheader')
	{
		$insertThumbheader="insert into thumb_header set adspaceId='".$adspaceId."', thHeaderFontSize='".$thHeaderFontSize."', thHeaderFontType='".$thHeaderFontType."', thHeaderFontColor='".$thHeaderFontColor."', thHeaderAlign='".$thHeaderAlign."', thHeaderAttriItalic='".$thHeaderAttriItalic."', thHeaderAttriBold='".$thHeaderAttriBold."', thHeaderAttriUnderline ='".$thHeaderAttriUnderline."'";
		//echo $insertThumbheader;

		$exeThumbheader=mysql_query($insertThumbheader);
	}
	if($_REQUEST['insertmode']=='insertbody')
	{
		
		$insertThumbBody="insert into thumb_body set adspaceId='".$adspaceId."', thumbBodyFontSize='".$thumbBodyFontSize."', thumbBodyFontType='".$thumbBodyFontType."', thumbBodyFontColor='".$thumbBodyFontColor."', thumbBodyAlign='".$thumbBodyAlign."', thumbBodyAttriItalic='".$thumbBodyAttriItalic."', thumbBodyAttriBold='".$thumbBodyAttriBold."', thumbBodyAttriUnderline ='".$thumbBodyAttriUnderline."'";
		//echo $insertThumbBody;

		$exeThumbBody=mysql_query($insertThumbBody);
	}

	$_SESSION['adspaceId']=$adspaceId;

	//}
	//else
	//{

	//$upDateThumbData = "update adspace_details set adspaceType='".$_POST['adspace_type']."',adSize='".$_POST['size']."',fontType='".$_POST['font_type']."',backgroundColor='".$_POST['background_color']."',noOfTextAd='".$_POST['cell_count']."',headerColor='".$_POST['title_color']."',thumbOrientation='".$_POST['alignment']."',bodyColor='".$_POST['description_color']."' where UserId='".$siteUserId."' and adspaceId='".$adspaceId."'";
	//echo $upDateAd;
	//$exeThumbData = mysql_query($upDateThumbData);
	//echo '<script>window.location="customize_ad.php?sid='.$siteUserId.'"</script>';
	//}
header("location:sell_space_add_details.php");
	
	}

?>

<link rel="stylesheet" href="css/style.css" type="text/css">
  
  <script type="text/javascript" language="javascript" src="JavaScripts/common.js"></script>
  <script type="text/javascript" language="javascript" src="JavaScripts/popup-layer.js"></script>
  <script type="text/javascript" language="javascript" src="JavaScripts/category-list.js"></script>
  <script type="text/javascript" language="javascript" src="JavaScripts/cover.js"></script>

<div id="colorlayer" onmouseover="javascript:enterColorPalette()" onmouseout="javascript:leaveColorPalette()" class="drag" style="visibility: hidden; width: 204px; height: 142px; position: absolute; z-index: 4;">
  <table bgcolor="#ffffff" border="0" cellpadding="1" cellspacing="2" width="100%">
    <tbody>
    <tr>
        <td id="selectedcolor" width="12%"></td>
        <td id="colorcode" align="center" width="75%"></td>
        <td width="12%">
          <div id="transparent" style="cursor: pointer; visibility: inherit;">
            <img src="images/transparent.gif" onmouseover="javascript:onTransparent();" onclick="javascript:onClickTransparent();preview();">
          </div>
        </td>
    </tr>
    </tbody>
  </table>
  <table id="colortable" style="border: 1px solid rgb(127, 157, 185); cursor: pointer; height: 115px;" bgcolor="#ffffff" border="0" cellpadding="1" cellspacing="2" width="100%">
    <tbody></tbody>
  </table>
  <iframe src="selling-gtb-adspace-add_files/blank_003.html" style="position: absolute; visibility: inherit; top: 0px; left: 0px; width: 204px; height: 142px; z-index: -1;" frameborder="0">
  </iframe>
</div>

<script language="javascript" type="text/javascript">
<!--
    var transparent = "TRANSPARENT";

    var ns = document.getElementById&&!document.all; //boolean flag for netscape/firefox
    var objId; //object id
    var selected; //selected color
    var onchangeFlag = false;
    init();

    //Initialize the color table.
    function init() {
        var colors = new Array (
            ['#FF8080', '#FFFF80', '#80FF80', '#00FF80', '#80FFFF', '#0080FF', '#FF80C0', '#FF80FF'],
            ['#FF0000', '#FFFF00', '#80FF00', '#00FF40', '#00FFFF', '#0080C0', '#8080C0', '#FF00FF'],
            ['#804040', '#FF8040', '#00FF00', '#008080', '#004080', '#8080FF', '#800040', '#FF0080'],
            ['#800000', '#FF8000', '#008000', '#008040', '#0000FF', '#0000A0', '#800080', '#8000FF'],
            ['#400000', '#804000', '#004000', '#004040', '#000080', '#000040', '#400040', '#400080'],
            ['#000000', '#808000', '#808040', '#808080', '#408080', '#C0C0C0', '#400040', '#FFFFFF']
        );
        var table = document.getElementById("colortable");

        for (itr in colors) {
            var row = table.insertRow(-1);
            for (itd in colors[itr]) {
                var cell = row.insertCell(-1);
                cell.height = 17;
                cell.innerText = "";
                cell.bgColor = colors[itr][itd];

                //when move mouse to a cell, the selected color will changed
                cell.onmouseover = function() {
                    var colorcode = document.getElementById("colorcode");
                    colorcode.innerHTML = "<b>" + this.bgColor.toUpperCase() + "</b>";
                    var selectedcolor = document.getElementById("selectedcolor");
                    selectedcolor.bgColor = this.bgColor;
                    selected = selectedcolor;
                }
                //when mouse click, the selected color will be assigned to obj
                //and color palette will be closed
                cell.onclick  = function(){
                    if (objId != '') {
                        var obj = document.getElementById(objId);
                    }
                    obj.value = selected.bgColor.toUpperCase();
                    if (obj.onchange) {
                        obj.onchange();
                    }
                    onClickPalette('', null);
                    preview();
                };
            }
        }
    }


    //It is called when mouse over transparent cell
    function onTransparent() {
        var colorcode = document.getElementById("colorcode");
        colorcode.innerHTML = "<b>" + transparent + "</b>";
        var selectedcolor = document.getElementById("selectedcolor");
        selectedcolor.bgColor = "Transparent";
    }


    //It is called when mouseclick on transparent cell
    function onClickTransparent() {
        if (objId != '') {
            var obj = document.getElementById(objId);
        }
        obj.value = 'TRANSPARENT';
        onClickPalette('', null);
    }

    //show or hide the palette
    //it also inits table data and div position
    function onClickPalette(objid, control, isTran, leftTopDisplay) {
        if (!document.all && onchangeFlag) {
            return;
        }
        var l = 0;
        var t = 0;
        var obj;
        if (objid != '') {
            obj = document.getElementById(objid);
            objId = objid;
        }

        //check that needs the transparent or not
        var transparent = document.getElementById("transparent");
        if (typeof(isTran) != "undefined") {
            transparent.style.visibility = (isTran) ? "inherit" : "hidden";
        }
        else {
            transparent.style.visibility = "hidden";
        }

        //calculate the control position
        if (control != null) {
            controlTop = control.offsetTop;
            controlLeft = control.offsetLeft + 20;
            while(control = control.offsetParent) {
                controlTop += control.offsetTop;
                controlLeft += control.offsetLeft;
            }
        }

        //init div position
        var div = document.getElementById('colorlayer');
        if (leftTopDisplay != null) {
            leftDistance = controlLeft - div.offsetWidth;
            topDistance = controlTop - div.offsetHeight;
            div.style.left = leftDistance + "px";
            div.style.top = topDistance + "px";
        }
        else {
            div.style.left = controlLeft + "px";
            div.style.top = controlTop + "px";
        }

        //init div data
        if (div.style.visibility == 'hidden') {
            var selectedcolor = document.getElementById('selectedcolor');
            selectedcolor.bgColor = obj.value;
            var colorcode = document.getElementById('colorcode');
            colorcode.innerHTML = "<b>" + obj.value.toUpperCase() + "</b>";
        }

        div.style.visibility = (div.style.visibility == 'hidden') ? 'visible' : 'hidden';
    }

    var inColorPalette = false;
    function mousedown() {
        if (!inColorPalette) {
            var div = document.getElementById('colorlayer');
            div.style.visibility = 'hidden';
        }
    }

    function leaveColorPalette() {
        inColorPalette=false;
    }

    function enterColorPalette() {
        inColorPalette=true;
    }

    document.onmousedown = mousedown;

-->
</script>
<table width="100%" class="center" cellspacing="0" cellpadding="0">
  
  <tr>
    <td align="left" valign="top" >

	
<form id="gtbLayout" name="gtb_layout" action="" method="post">
<input id="themeId" name="theme_id" value="0" type="hidden">
<table style="margin-left: 5px;" class="normal-table" align="center">
  <tbody><tr valign="top">
    <td style="width: 50%;">
    <table style="background-color: rgb(153, 153, 153); width: 100%;" cellpadding="3" cellspacing="1">
  <tbody><tr>
    <td style="text-align: left; color: rgb(255, 255, 255); font-weight: bold;" class="sitename">Ad Space Characteristics</td>
  </tr>
  <tr style="background-color: rgb(251, 251, 251);">
    <td>
      <div style="padding: 3px; text-align: left;">
      <table style="text-align: left;" class="normal-table" align="center">
        <tbody><tr>
          <td colspan="2" class="blackbold" style="text-align: left;">
            Ad Space Type:
            <select id="adspaceType" name="adspace_type" class="flat blackbold" onchange="var newValue=this.value;this.selectedIndex=2;window.location.href=newValue;">
	      <option value="text" onclick="window.location='customize_ad.php'">Text</option>
	      <option value="banner" onclick="window.location='customize_banner.php'">Banner</option>
	      <option value="thumbnail" selected="selected" onclick="window.location='customize_thumbnail.php'">Thumbnail</option>
	      <option value="customize_commBreak" onclick="window.location='customize_commBreak.php'">Commercial Break</option>
           </select>
          </td>
        </tr>
        <tr><td colspan="2"><hr></td></tr>
        <tr>
          <td>Choose a Web Site:</td>
          <td>
            <select id="siteId" name="site_id" class="flat">
              <option label="Please Select" value="0" selected="selected">Please Select</option>
<!--<option label="esolzdemos(NSFW)" value="72687">esolzdemos(NSFW)</option>
<option label="test(NSFW)" value="72719">test(NSFW)</option>-->
<?php
		while($fetSiteUrl=mysql_fetch_array($selSiteurl))
		{
?>
		<option label="<?=$fetSiteUrl['adSiteUrl']?>" value="<?=$fetSiteUrl['adsiteId']?>"><?=$fetSiteUrl['adSiteUrl']?></option>
<?php 		} ?>
            </select>
            
          </td>
        </tr>
        <!--<tr>
          <td>Rating:</td>
          <td>
            <div id="websiteRating"></div>
          </td>
        </tr>-->
        <script type="text/javascript" language="javascript" src="js.html"></script>
<script type="text/javascript" language="javascript" src="JavaScripts/form.js"></script>

<tr>
  <td colspan="2" style="margin: 0px; padding: 0px;"><hr></td>
</tr>
<tr>
  <td colspan="2">
    <fieldset style="margin: 0px; padding: 0px;">
      <legend style="padding: 0px 5px; margin-left: 5px;">Components</legend>
      <table style="text-align: left; line-height: 18px;">
      <tbody><tr>
                <td>
          <input id="component_handle" name="handle" checked="checked" onclick="javascript:isChanged = true;setComponent(this);" type="checkbox"><label style="cursor: pointer;" for="component_handle">Handle</label>
        </td>
                        <td>
          <input id="component_age" name="age" checked="checked" onclick="javascript:isChanged = true;setComponent(this);" type="checkbox"><label style="cursor: pointer;" for="component_age">Age</label>
        </td>
                        <td>
          <input id="component_location" name="location" checked="checked" onclick="javascript:isChanged = true;setComponent(this);" type="checkbox"><label style="cursor: pointer;" for="component_location">Location</label>
        </td>
              </tr>
      <tr>
                        <td>
          <input id="component_headline" name="headline" checked="checked" onclick="javascript:isChanged = true;setComponent(this);" type="checkbox"><label style="cursor: pointer;" for="component_headline">Headline</label>
        </td>
                        <!--<td>
          <input id="component_brokerLink" name="brokerLink" checked="checked" onclick="javascript:isChanged = true;setComponent(this);" type="checkbox"><label style="cursor: pointer;" for="component_brokerLink">Broker Link</label>
        </td>-->
                        <td>
          <input id="component_image" name="image" checked="checked" onclick="javascript:isChanged = true;setComponent(this);" type="checkbox"><label style="cursor: pointer;" for="component_image">Image</label>
        </td>
              </tr>
      <tr>
                        <td>
          <input style="display: none;" id="component_header" name="header" checked="checked" onclick="javascript:isChanged = true;setComponent(this);" type="checkbox"><label style="cursor: pointer; display: none;" for="component_header">Header</label>
        </td>
                        <td></td>
      </tr>
      </tbody></table>
        <script type="text/javascript" language="javascript">
        //fixed bug #3888, Header checkbox shall only be available when it is off/unchecked
        var headerComponent = document.getElementById('component_header');
        if (headerComponent.checked) {
            headerComponent.style.display = 'none';
            headerComponent.nextSibling.style.display = 'none';
        }
        </script>
    </fieldset>
  </td>
</tr>
<tr>
  <td colspan="2"><hr></td>
</tr><tr>
  <td colspan="2">
    <fieldset>
      <legend style="padding: 0px 5px; margin-left: 5px;">Thumbs</legend>
      <div style="padding: 3px;">
        Size:
        <select class="flat" id="thumbSize" name="thumb_size" onchange="javascript:isChanged = true;setImageSize(this.value);">
          <option label="40x40" value="40x40">40x40</option>
<option label="60x60" value="60x60" selected="selected">60x60</option>
<option label="80x80" value="80x80">80x80</option>
<option label="100x100" value="100x100">100x100</option>
<option label="120x120" value="120x120">120x120</option>
<option label="140x140" value="140x140">140x140</option>
<option label="160x160" value="160x160">160x160</option>

        </select>&nbsp;&nbsp;&nbsp;&nbsp;
        View:
        <select class="flat" id="thumbCount" name="thumb_count" onchange="javascript:isChanged = true;previewer.setCount(this.value);">
          <option label="1" value="1">1</option>
<option label="2" value="2">2</option>
<option label="3" value="3">3</option>
<option label="4" value="4" selected="selected">4</option>
<option label="5" value="5">5</option>
<option label="6" value="6">6</option>
<option label="7" value="7">7</option>
<option label="8" value="8">8</option>
<option label="9" value="9">9</option>
<option label="10" value="10">10</option>

        </select>
      </div>
    </fieldset>
  </td>
</tr>
<tr>
  <td colspan="2"><hr></td>
</tr>
<tr>
  <td colspan="2">
    <fieldset>
      <legend style="padding: 0px 5px; margin-left: 5px;">Thumbnail Size (pixels)</legend>
      <table style="width: 100%;">
        <tbody><tr>
          <td>Width:</td>
          <td>
            <input id="width" name="width" class="flat" value="264" style="width: 80px; color: rgb(128, 128, 128);" readonly="readonly" onkeyup="javascript:isChanged = true;setSize(gtbWidthInputElement.value, gtbHeightInputElement.value);" type="text">
          </td>
          <td>Height:</td>
          <td>
            <input id="height" name="height" class="flat" value="212" style="width: 80px; color: rgb(128, 128, 128);" readonly="readonly" onkeyup="javascript:isChanged = true;setSize(gtbWidthInputElement.value, gtbHeightInputElement.value);" type="text">
          </td>
        </tr>
<script language="javascript" type="text/javascript">
<!--
function enableCustomGtbSize(checkBox) {
    if (checkBox.checked) {
        gtbWidthInputElement.readOnly = false;
        gtbHeightInputElement.readOnly = false;
        gtbWidthInputElement.style.color = '#000000';
        gtbHeightInputElement.style.color = '#000000';
        setSize(gtbWidthInputElement.value, gtbHeightInputElement.value);
    }
    else {
        gtbWidthInputElement.readOnly = true;
        gtbHeightInputElement.readOnly = true;
        gtbWidthInputElement.style.color = '#808080';
        gtbHeightInputElement.style.color = '#808080';
        setSize();
    }
}

function popupStyleWindow(id,inmode) {
    header = document.getElementById('headerContentStyle');
    body = document.getElementById('bodyContentStyle');
    //borker = document.getElementById('brokerLinkStyle');

    //closes all style windows first
    header.style.display = 'none';
    body.style.display = 'none';
    //borker.style.display = 'none';

    document.getElementById(id).style.display = '';

    window.scrollTo(0, document.getElementById(id).offsetTop);
document.getElementById('insertmode').value = inmode;

}
var gtbWidthInputElement = document.getElementById('width');
var gtbHeightInputElement = document.getElementById('height');
var windowOnload = window.onload;
window.onload = function() {
    if (windowOnload) {
        windowOnload();
    }
    enableCustomGtbSize(document.getElementById('customGtbSize'));
}
-->
</script>
        <tr>
          <td colspan="4">
            <input id="customGtbSize" name="custom_gtb_size" onclick="javascript:isChanged = true;enableCustomGtbSize(this);" type="checkbox">
            <label style="cursor: pointer;" for="customGtbSize">Custom Thumbnail Size</label>
          </td>
        </tr>
      </tbody></table>
    </fieldset>
  </td>
</tr>
<tr>
  <td colspan="2"><hr></td>
</tr>
<tr>
  <td>Background Color:</td>
  <td>
    <input id="backgroundColor" name="background_color" class="flat" size="10" maxlength="11" value="#80FF00" onchange="javascript: isChanged = true;commonPreview(preview);" type="text"><a class="colorformat">Background Color</a>
    <img style="cursor: pointer; padding-left: 3px;" src="images/palette.gif" alt="Palette" onclick="javascript: onClickPalette('backgroundColor', this, true);">
  </td>
</tr>
<tr>
  <td>Orientation:</td>
  <td>
    <input id="horizontal" name="alignment" value="horizontal" checked="checked" onclick="javascript:isChanged = true;setView();" type="radio">
    <label style="cursor: pointer;" for="horizontal">Horizontal</label>
    <input id="vertical" name="alignment" value="vertical" onclick="javascript:isChanged = true;setView();" type="radio">
    <label style="cursor: pointer;" for="vertical">Vertical</label>
  </td>
</tr>
<tr>
  <td colspan="2"><hr></td>
</tr>
<tr>
  <td colspan="2">
    <fieldset>
      <legend>Thumbnail Appearance</legend>
      <table cellpadding="0" cellspacing="0" width="100%">
        <tbody><tr><td width="50%"></td><td width="50%"></td></tr>
        <tr>
          <td colspan="2">Click on banner or links below to control appearance.</td>
        </tr>
        <tr>
		<input type="hidden" name="insertmode" id="insertmode">
          <td>
            <span style="cursor: pointer;" onclick="javascript:popupStyleWindow('headerContentStyle','insertheader')"><img src="images/a-b.gif" alt="">&nbsp;Header</span>
          </td>
          <td>
            <span style="cursor: pointer;" onclick="javascript:popupStyleWindow('bodyContentStyle','insertbody')"><img src="images/a-b.gif" alt="">&nbsp;Body</span>
          </td>
        </tr><!--
        <tr>
          <td>
            <span style="cursor: pointer;" onclick="javascript:popupStyleWindow('brokerLinkStyle')"><img src="images/a-b.gif" alt="">&nbsp;Broker Link</span>
          </td>
          <td>
          </td>
        </tr>-->
      </tbody></table>
    </fieldset>
  </td>
</tr>
<tr>
  <td colspan="2" style="text-align: center;">
    <a href="javascript: restoreDefault(); void 0;">restore defaults</a>
  </td>
</tr>
<tr>
  <td colspan="2">
        <div><input id="allowNetwork" name="allow_network" checked="checked" onchange="javascript:isChanged = true;" onclick="checkSelect(this);" type="checkbox"><label style="padding-left: 5px;" for="allowNetwork" class="blackbold">Allow Network Ads</label></div>
    
      </td>
</tr>
<script language="javascrip" type="text/javascript">
<!--
var message_warning_not_allow_network = "Warning! Network ads allow this ad space to always generate revenue, regardless of a direct ad purchase. If you choose to continue, please set your desired sale price for this ad space.";
function checkSelect(obj) {
    if (false == obj.checked) {
        if(!confirm(message_warning_not_allow_network)) {
            obj.checked = true;
        }
    }
}
-->
</script>      </tbody></table>
          </div>
    </td>
  </tr>
</tbody></table>
    <div style="text-align: right; padding-top: 10px;">
      <input id="gtbAdSpace" name="gtb_adspace" value="" disabled="disabled" type="hidden">
      <input name="back" value="&lt; Back" class="blank-button-small" onclick="javascript:void();" type="button">
      <input name="next" value="Next &gt;" class="yellow-button-small" onclick="javascript: return validateSite(); " type="submit">
    </div>
    </td>
    <td style="width: 50%;">
    <table style="background-color: rgb(153, 153, 153); width: 100%;" cellpadding="3" cellspacing="1">
  <tbody><tr>
    <td style="text-align: left; color: rgb(255, 255, 255); font-weight: bold;" class="sitename">Preview</td>
  </tr>
  <tr style="background-color: rgb(251, 251, 251);">
    <td>
      <div style="padding: 3px; text-align: left;">
      <div><script type="text/javascript" language="javascript" src="js.html"></script>
	<script type="text/javascript" src="JavaScripts/gtb-previewer.js"></script>
<!--<script type="text/javascript" src="JavaScripts/common.js"></script>-->
<script language="javascript" type="text/javascript">
<!--
var title = "Header Goes Here";
var titleField = false;
if ((titleField = document.getElementById('headline'))
        && (titleField.type) && ('text' == titleField.type)
        && ('' != titleField.value)) {
    title = titleField.value;
}

var ad = {
    //requestURL: 'show-gallery-entry.php',
    spacer: 'images/spacer.gif',
    //baseURL: '?sid=2d47b082c2e464ec257bb48468c0ddfb',
    space: {
        rating: 'sfw',
        themeId: 1,
        style: {
                    cells: 4,
            view: 'horizontal',
            backgroundColor: '#6cdae7',
            imageWidth: 60,
            imageHeight: 60,
            showHandle:  true ,
            showAge:  true ,
            showLocation:  true ,
            showHeadline:  true ,
            showBrokerLink:  true ,
            showImage:  true ,
            showHeader:  true ,
            headStyle: 'fontFamily:Arial;fontSize:15px;color:#000000;textDecoration:none;fontWeight:bold;fontStyle:normal;textAlign:center',
            bodyStyle: 'fontFamily:Arial;fontSize:13px;color:#000000;textDecoration:none;fontWeight:normal;fontStyle:normal;textAlign:center',
//             brokerLinkStyle: 'fontFamily:Arial;fontSize:11px;color:#000000;textDecoration:none;fontWeight:normal;fontStyle:normal;textAlign:center'
        }
    },
    payment: {
        title: title
    },
    location: {
            //latitude: 22.5697,
       // longitude: 88.3697,
        //cityName: 'Calcutta',
            nearbyCities: []
    }
};

function setComponent(checkBox) {
    previewer.setComponent(checkBox.name, checkBox.checked);
}

function setImageSize(size) {
    size = size.toLowerCase().split('x');
    previewer.setImageSize(size[0], size[1]);
}

function setSize(width, height) {
    if (2 != arguments.length) {
        previewer.setSize();
    }
    else {
        previewer.setSize(width, height);
    }
}

function setView() {
    if (document.getElementById('horizontal').checked) {
        previewer.setView(GTBPreviewer.HORIZONTAL);
    }
    else {
        previewer.setView(GTBPreviewer.VERTICAL);
    }
}

function closeStyleWindow(id) {
    document.getElementById(id).style.display='none';
}

function editStyle(self, targetSytleEditId) {
    obj = document.getElementById(targetSytleEditId);

    var top;
    var left;
    var xOffset;
    var yOffset;
    var windowWidth;
    var windowHeight;

    var isIE = document.all ? true : false;

    if (isIE) {
        var htmlObj = document.getElementsByTagName('html')[0];
        left = event.x + htmlObj.scrollLeft;
        top = event.y + htmlObj.scrollTop;
        xOffset = event.x;
        yOffset = event.y;
        windowWidth = htmlObj.clientWidth;
        windowHeight = htmlObj.clientHeight;
    }
    else {
        document.captureEvents(Event.MOUSEMOVE);
        left = self.pageX;
        top = self.pageY;
        xOffset = self.pageX - window.scrollX;
        yOffset = self.pageY - window.scrollY;
        windowWidth = window.innerWidth - 20;
        windowHeight = window.innerHeight;
    }
    obj.style.top = top + "px";
    obj.style.left = left + "px";
    document.getElementById("headerContentStyle").style.display = "none";
    document.getElementById("bodyContentStyle").style.display = "none";
    document.getElementById("brokerLinkStyle").style.display = "none";
    obj.style.display = "";

    //adjusts the position of style window
    if (xOffset + obj.offsetWidth > windowWidth) {
        obj.style.left = left - obj.offsetWidth + "px";
    }

    if (yOffset + obj.offsetHeight > windowHeight) {
        obj.style.top = top - obj.offsetHeight + "px";
    }
}

function editHeadStyle(e) {
    editStyle(e, "headerContentStyle");
}

function editBodyStyle(e) {
    editStyle(e, "bodyContentStyle");
}

function editBrokerLinkStyle(e) {
    editStyle(e, "brokerLinkStyle");
}

function compareColor() {
    var backgroundColorField = document.getElementById("backgroundColor");
    var titleColorField = document.getElementById("title_font_color");
    var descriptionColorField = document.getElementById("description_font_color");
    var brokerColorField = document.getElementById("broker_link_font_color");
    var colorReg = /^#[0-9a-fA-F]{6}$/;
    if ('TRANSPARENT' != backgroundColorField.value && ! colorReg.test(backgroundColorField.value)) {
        alert(alert_color_incorrect.replace('<field name>', backgroundColorField.nextSibling.firstChild.nodeValue));
        focusElement(backgroundColorField);
        return;
    }
    if (! colorReg.test(titleColorField.value)) {
        alert(alert_color_incorrect.replace('<field name>', titleColorField.nextSibling.firstChild.nodeValue));
        focusElement(titleColorField);
        return;
    }
    if (! colorReg.test(descriptionColorField.value)) {
        alert(alert_color_incorrect.replace('<field name>', descriptionColorField.nextSibling.firstChild.nodeValue));
        focusElement(descriptionColorField);
        return;
    }
    if (! colorReg.test(brokerColorField.value)) {
        alert(alert_color_incorrect.replace('<field name>', brokerColorField.nextSibling.firstChild.nodeValue));
        focusElement(brokerColorField);
        return;
    }
    var titleColor = titleColorField ? titleColorField.value : previewer.style.head.lastFontColor;

    if (!colorReg.test(titleColor) ||
        (!colorReg.test(backgroundColorField.value) && ('TRANSPARENT' != backgroundColorField.value))) {
        return false;
    }

    if (backgroundColorField.value.toUpperCase() == titleColor.toUpperCase()) {
        alert("Background color and font colors cannot be the same.");
        backgroundColorField.value = previewer.style.lastBackgroundColor;
        titleColorField.value = previewer.style.head.lastFontColor;
        return false;
    }

    return true;
}

function preview() {
    if (!compareColor()) return;
    previewer.style.lastBackgroundColor = document.getElementById('backgroundColor').value;
    previewer.style.head.lastFontColor = document.getElementById('title_font_color').value;
    previewer.setBackgroundColor(document.getElementById("backgroundColor").value);
    previewer.setStyle('head', 'color', document.getElementById("title_font_color").value);
    previewer.setStyle('body', 'color', document.getElementById("description_font_color").value);
    previewer.setStyle('brokerLink', 'color', document.getElementById("broker_link_font_color").value);
}

var previewer = new GTBPreviewer(ad);
previewer.render();
previewer.style.lastBackgroundColor = previewer.style.background;
previewer.style.head.lastFontColor = previewer.style.head.color;
var warning = document.createElement('div');
warning.style.display = 'none';
previewer.adBlock.parentNode.insertBefore(warning, previewer.adBlock);
var warningMessage = 'The ad cannot be shown correctly because the specified size is too small.';
warning.innerHTML = '<span class="warning">Warning: ' + warningMessage + '</span><br /><br />';
previewer.onOverflow = function (isOverflow) {
    warning.style.display = isOverflow ? 'block' : 'none';
}

    previewer.setHeadOnClickHandler(editHeadStyle);
    previewer.setBodyOnClickHandler(editBodyStyle);
    previewer.setBrokerLinkOnClickHandler(editBrokerLinkStyle);

    if (gtbWidthInputElement && gtbWidthInputElement) {
        previewer.onSizeChange = function (width, height) {
            gtbWidthInputElement.value = width;
            gtbHeightInputElement.value = height;
        }
    }
// -->
</script>

<div id="bodyContentStyle" style="display: none; position: absolute; width: 280px;">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
  <tbody>
  <tr>
    <td style="width: 11px; height: 11px;"><img src="images/top-left.gif" alt=""></td>
    <td style="width: 100%; background-image: url(images/top-mid.gif); background-repeat: repeat;"></td>
    <td style="width: 11px;"><img src="images/top-right.gif" alt=""></td>
  </tr>
  <tr>
    <td style="width: 11px; background-image: url(images/left-mid.gif); background-repeat: repeat;"></td>
    <td style="background: rgb(249, 247, 247) none repeat scroll 0%; width: 100%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">
<table width="100%">
  <tbody><tr>
    <td style="text-align: center;">Body Style Edit</td>
    <td style="width: 16px;">
      <img style="cursor: pointer;" src="images/closing-button.bmp" alt="" onclick="javascript:closeStyleWindow('bodyContentStyle')">
    </td>
  </tr>
</tbody>
</table>
<table style="text-align: left;">
  <tbody><tr>
    <td>Font Size:</td>
    <td>
      <select id="description_font_size" class="flat" name="description_font_size" onchange="javascript:isChanged = true;previewer.setStyle('body', 'fontSize', this.value+'px');">
        <option label="1" value="8">1</option>
<option label="2" value="9">2</option>
<option label="3" value="10">3</option>
<option label="4" value="11">4</option>
<option label="5" value="12">5</option>
<option label="6" value="13" selected="selected">6</option>
<option label="7" value="14">7</option>
<option label="8" value="15">8</option>
<option label="9" value="16">9</option>
<option label="10" value="17">10</option>

     </select> points
    </td>
  </tr>
  <tr>
    <td>Font Type:</td>
    <td>
      <select class="flat" id="description_font_type" name="description_font_type" onchange="javascript:isChanged = true;previewer.setStyle('body', 'fontFamily', this.value);">
        <option label="Arial" value="Arial" selected="selected">Arial</option>
<option label="Georgia" value="Georgia">Georgia</option>
<option label="Sans-serif" value="MS Sans Serif">Sans-serif</option>
<option label="Times" value="Times">Times</option>
<option label="Verdana" value="Verdana">Verdana</option>

      </select>
    </td>
  </tr>
  <tr>
    <td>Color:</td>
    <td>
      <input id="description_font_color" name="description_font_color" class="flat" size="10" maxlength="10" value="#000000" onchange="javascript:isChanged = true;commonPreview(preview);" type="text"><a class="colorformat">Body Color</a>
      <img style="cursor: pointer; padding-left: 3px;" src="images/palette.gif" alt="Palette" onclick="javascript:onClickPalette('description_font_color', this, false);">
    </td>
  </tr>
  <tr>
    <td>Attributes:</td>
    <td>
      <input id="description_bold" name="description_bold" size="25" value="Bold" onclick="javascript:isChanged = true;var value=this.checked?'bold':'normal'; previewer.setStyle('body', 'fontWeight', value);" type="checkbox">
      <label style="cursor: pointer;" for="description_bold">Bold</label>
      <input id="description_underline" name="description_underline" size="25" value="Underline" onclick="isChanged = true;var value=this.checked?'underline':'none'; previewer.setStyle('body', 'textDecoration', value);" type="checkbox">
      <label style="cursor: pointer;" for="description_underline">Underline</label>
      <input id="description_italic" name="description_italic" size="25" value="Italic" onclick="isChanged = true;var value=this.checked?'italic':'normal'; previewer.setStyle('body', 'fontStyle', value);" type="checkbox">
      <label style="cursor: pointer;" for="description_italic">Italic</label>
    </td>
  </tr>
  <tr>
    <td>Horizontal Align:</td>
    <td>
      <select class="flat" id="description_align" name="description_align" onchange="javascript:isChanged = true;previewer.setStyle('body', 'textAlign', this.value);">
        <option value="left">Left</option>
        <option value="center" selected="selected">Center</option>
        <option value="right">Right</option>
      </select>
    </td>
  </tr>
</tbody></table>
    </td>
    <td style="width: 11px; background-image: url(images/right-mid.gif); background-repeat: repeat;"></td>
  </tr>
  <tr>
    <td style="height: 11px;"><img src="images/bottom-left.gif" alt=""></td>
    <td style="width: 100%; background-image: url(images/bottom-mid.gif); background-repeat: repeat;"></td>
    <td><img src="images/bottom-right.gif" alt=""></td>
  </tr>
  </tbody>
</table>
</div>

<div id="headerContentStyle" style="display: none; position: absolute; width: 280px;">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
  <tbody>
  <tr>
    <td style="width: 11px; height: 11px;"><img src="images/top-left.gif" alt=""></td>
    <td style="width: 100%; background-image: url(images/top-mid.gif); background-repeat: repeat;"></td>
    <td style="width: 11px;"><img src="images/top-right.gif" alt=""></td>
  </tr>
  <tr>
    <td style="width: 11px; background-image: url(images/left-mid.gif); background-repeat: repeat;"></td>
    <td style="background: rgb(249, 247, 247) none repeat scroll 0%; width: 100%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">
<table width="100%">
  <tbody><tr>
    <td style="text-align: center;">Header Style Edit</td>
    <td style="width: 16px;">
      <img style="cursor: pointer;" src="images/closing-button.bmp" alt="" onclick="javascript:closeStyleWindow('headerContentStyle')">
    </td>
  </tr>
</tbody></table>
<table style="text-align: left;">
  <tbody><tr>
    <td>Font Size:</td>
    <td>
      <select id="title_font_size" class="flat" name="title_font_size" onchange="javascript:isChanged = true;previewer.setStyle('head', 'fontSize', this.value+'px');">
        <option label="1" value="8">1</option>
<option label="2" value="9">2</option>
<option label="3" value="10">3</option>
<option label="4" value="11">4</option>
<option label="5" value="12">5</option>
<option label="6" value="13">6</option>
<option label="7" value="14">7</option>
<option label="8" value="15" selected="selected">8</option>
<option label="9" value="16">9</option>
<option label="10" value="17">10</option>

      </select> points
    </td>
  </tr>
  <tr>
    <td>Font Type:</td>
    <td>
      <select class="flat" id="title_font_type" name="title_font_type" onchange="javascript:isChanged = true;previewer.setStyle('head', 'fontFamily', this.value);">
        <option label="Arial" value="Arial" selected="selected">Arial</option>
<option label="Georgia" value="Georgia">Georgia</option>
<option label="Sans-serif" value="MS Sans Serif">Sans-serif</option>
<option label="Times" value="Times">Times</option>
<option label="Verdana" value="Verdana">Verdana</option>

      </select>
    </td>
  </tr>
  <tr>
    <td>Color:</td>
    <td>
      <input id="title_font_color" name="title_font_color" class="flat" size="10" maxlength="10" value="#000000" onchange="javascript:isChanged = true;commonPreview(preview);" type="text"><a class="colorformat">Headline Color</a>
      <img style="cursor: pointer; padding-left: 3px;" src="images/palette.gif" alt="Palette" onclick="javascript: onClickPalette('title_font_color', this, false);">
    </td>
  </tr>
  <tr>
    <td>Attributes:</td>
    <td>
      <input id="title_bold" name="title_bold" size="25" value="Bold" checked="checked" onclick="javascript:isChanged = true;var value=this.checked?'bold':'normal'; previewer.setStyle('head', 'fontWeight', value);" type="checkbox">
      <label style="cursor: pointer;" for="title_bold">Bold</label>
      <input id="title_underline" name="title_underline" size="25" value="Underline" onclick="isChanged = true;var value=this.checked?'underline':'none'; previewer.setStyle('head', 'textDecoration', value);" type="checkbox">
      <label style="cursor: pointer;" for="title_underline">Underline</label>
      <input id="title_italic" name="title_italic" size="25" value="Italic" onclick="isChanged = true;var value=this.checked?'italic':'normal'; previewer.setStyle('head', 'fontStyle', value);" type="checkbox">
      <label style="cursor: pointer;" for="title_italic">Italic</label>
    </td>
  </tr>
  <tr>
    <td>Horizontal Align:</td>
    <td>
      <select class="flat" id="title_align" name="title_align" onchange="javascript:isChanged = true;previewer.setStyle('head', 'textAlign', this.value);">
        <option value="left">Left</option>
        <option value="center" selected="selected">Center</option>
        <option value="right">Right</option>
      </select>
    </td>
  </tr>
</tbody></table>
    </td>
    <td style="width: 11px; background-image: url(images/right-mid.gif); background-repeat: repeat;"></td>
  </tr>
  <tr>
    <td style="height: 11px;"><img src="images/bottom-left.gif" alt=""></td>
    <td style="width: 100%; background-image: url(images/bottom-mid.gif); background-repeat: repeat;"></td>
    <td><img src="images/bottom-right.gif" alt=""></td>
  </tr>
  </tbody>
</table>
</div>

<div id="brokerLinkStyle" style="display: none; position: absolute; width: 280px;">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
  <tbody>
  <tr>
    <td style="width: 11px; height: 11px;"><img src="images/top-left.gif" alt=""></td>
    <td style="width: 100%; background-image: url(images/top-mid.gif); background-repeat: repeat;"></td>
    <td style="width: 11px;"><img src="images/top-right.gif" alt=""></td>
  </tr>
  <tr>
    <td style="width: 11px; background-image: url(images/left-mid.gif); background-repeat: repeat;"></td>
    <td style="background: rgb(249, 247, 247) none repeat scroll 0%; width: 100%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">

<table style="text-align: left;">
  <tbody><tr>
    <td>Font Size:</td>
    <td>
      <select id="broker_link_font_size" class="flat" name="broker_link_font_size" onchange="javascript:isChanged = true;previewer.setStyle('brokerLink', 'fontSize', this.value+'px');">
            <option label="1" value="8">1</option>
<option label="2" value="9">2</option>
<option label="3" value="10">3</option>
<option label="4" value="11" selected="selected">4</option>
<option label="5" value="12">5</option>
<option label="6" value="13">6</option>
<option label="7" value="14">7</option>
<option label="8" value="15">8</option>
<option label="9" value="16">9</option>
<option label="10" value="17">10</option>

      </select> points
    </td>
  </tr>
  <tr>
    <td>Font Type:</td>
    <td>
      <select class="flat" id="broker_link_font_type" name="broker_link_font_type" onchange="javascript:isChanged = true;previewer.setStyle('brokerLink', 'fontFamily', this.value);">
        <option label="Arial" value="Arial" selected="selected">Arial</option>
<option label="Georgia" value="Georgia">Georgia</option>
<option label="Sans-serif" value="MS Sans Serif">Sans-serif</option>
<option label="Times" value="Times">Times</option>
<option label="Verdana" value="Verdana">Verdana</option>

      </select>
    </td>
  </tr>
  <tr>
    <td>Color:</td>
    <td>
      <input id="broker_link_font_color" name="broker_link_font_color" class="flat" size="10" maxlength="10" value="#000000" onchange="javascript:isChanged = true;commonPreview(preview);" type="text"><a class="colorformat">Broker Link Color</a>
      <img style="cursor: pointer; padding-left: 3px;" src="images/palette.gif" alt="Palette" onclick="javascript: onClickPalette('broker_link_font_color', this, false);">
    </td>
  </tr>
  <tr>
    <td>Attributes:</td>
    <td>
      <input id="broker_link_bold" name="broker_link_bold" size="25" value="Bold" onclick="javascript:isChanged = true;var value=this.checked?'bold':'normal'; previewer.setStyle('brokerLink', 'fontWeight', value);" type="checkbox">
      <label style="cursor: pointer;" for="broker_link_bold">Bold</label>
      <input id="broker_link_underline" name="broker_link_underline" size="25" value="Underline" onclick="javascript:isChanged = true;var value=this.checked?'underline':'none'; previewer.setStyle('brokerLink', 'textDecoration', value);" type="checkbox">
      <label style="cursor: pointer;" for="broker_link_underline">Underline</label>
      <input id="broker_link_italic" name="broker_link_italic" size="25" value="Italic" onclick="javascript:isChanged = true;var value=this.checked?'italic':'normal'; previewer.setStyle('brokerLink', 'fontStyle', value);" type="checkbox">
      <label style="cursor: pointer;" for="broker_link_italic">Italic</label>
    </td>
  </tr>
  <tr>
    <td>Horizontal Align:</td>
    <td>
      <select class="flat" id="broker_link_align" name="broker_link_align" onchange="javascript:isChanged = true;previewer.setStyle('brokerLink', 'textAlign', this.value);">
        <option value="left">Left</option>
        <option value="center" selected="selected">Center</option>
        <option value="right">Right</option>
      </select>
    </td>
  </tr>
</tbody></table>
    </td>
    <td style="width: 11px; background-image: url(images/right-mid.gif); background-repeat: repeat;"></td>
  </tr>
  <tr>
    <td style="height: 11px;"><img src="images/bottom-left.gif" alt=""></td>
    <td style="width: 100%; background-image: url(images/bottom-mid.gif); background-repeat: repeat;"></td>
    <td><img src="images/bottom-right.gif" alt=""></td>
  </tr>
  </tbody>
</table>
</div>
</div>
      <div style="margin-top: 10px;">Please Note: Click on a specific property to edit it.</div>
          </div>
    </td>
  </tr>
</tbody></table>
    </td>
  </tr>
</tbody></table>
</form>

<script language="javascrip" type="text/javascript">
<!--
var components = new Array();
components[components.length] = 'handle';
components[components.length] = 'age';
components[components.length] = 'location';
components[components.length] = 'headline';
//components[components.length] = 'brokerLink';
components[components.length] = 'image';
components[components.length] = 'header';
var websites_rating = new Array();
    websites_rating['72687'] = 'nsfw';
    websites_rating['72719'] = 'nsfw';
var default_theme = new Array();
    default_theme['sfw'] = '7';
    default_theme['nsfw'] = '6';
    default_theme['adult'] = '5';
var ratings = {'sfw' : 'Safe For Work', 'nsfw' : 'Not Safe For Work', 'adult' : 'Adult'};

function validateSite() {
    var form = document.getElementById("gtbLayout");

    if ("0" == document.getElementById("siteId").value) {
        alert("Please choose a website from the dropdown list");
        document.getElementById("siteId").focus();
        return false;
    }

    var selectComponents = 0;
        if (form.handle.checked) {
        selectComponents++;
    }
        if (form.age.checked) {
        selectComponents++;
    }
        if (form.location.checked) {
        selectComponents++;
    }
        if (form.headline.checked) {
        selectComponents++;
    }
        if (form.brokerLink.checked) {
        selectComponents++;
    }
        if (form.image.checked) {
        selectComponents++;
    }
        if (form.header.checked) {
        selectComponents++;
    }
        if (0 == selectComponents) {
        alert("Please select at least one component.");
        return false;
    }

    return validateForm(form);
}


function storeLayout() {
    document.getElementById('gtbAdSpace').disabled = false;
    document.getElementById('gtbLayout').submit();
    return false;
}

function setDefaultOption(names) {
    for(var i = 0; i < names.length; ++i) {
        var name = names[i];
        var options = document.gtb_layout[name].options;
        for(var j = 0; j < options.length; ++j) {
            options[j].selected = options[j].defaultSelected;
        }
    }
}

function setDefaultChecked(names) {
    for(var i = 0; i < names.length; ++i) {
        var it = document.gtb_layout[names[i]];
        it.checked = it.defaultChecked;
    }
}

//sets the fields to default
function resetForm() {
    setDefaultOption(['thumb_size', 'thumb_count',
            'description_font_size', 'description_font_type', 'description_align',
            'title_font_size', 'title_font_type', 'title_align',
            'broker_link_font_size', 'broker_link_font_type', 'broker_link_align']);
    setDefaultChecked(components.concat(['custom_gtb_size',
            'broker_link_bold', 'broker_link_underline', 'broker_link_italic',
            'title_bold', 'title_underline', 'title_italic',
            'description_italic', 'description_underline', 'description_bold']));
    document.gtb_layout.alignment[0].checked = document.gtb_layout.alignment[0].defaultChecked;
    document.gtb_layout.alignment[1].checked = document.gtb_layout.alignment[1].defaultChecked;
    document.gtb_layout.background_color.value = document.gtb_layout.background_color.defaultValue;
    document.gtb_layout.description_font_color.value = document.gtb_layout.description_font_color.defaultValue;
    document.gtb_layout.title_font_color.value = document.gtb_layout.title_font_color.defaultValue;
    
}

function restoreDefault() 
{
    document.getElementById('siteId').value = '0';
    document.getElementById('width').readOnly = true;
    document.getElementById('width').style.color = '#808080';
    document.getElementById('height').readOnly = true;
    document.getElementById('height').style.color = '#808080';
    resetForm();
    //changeRating();
    previewer.initialize(ad);
    previewer.refresh();
}

// function changeRating() {
//     var website = document.getElementById('siteId');
//     var themeId = document.getElementById('themeId');
//     var contentRating = ratings[websites_rating[website.value]];
//     document.getElementById('websiteRating').innerHTML = (contentRating) ? contentRating : '';
//     document.getElementById('noTheme').style.display = (contentRating) ? 'none' : 'inline';
//     themeId.value = '0';
//     var currentSelect = null;
//     for (rating in ratings) {
//         currentSelect = document.getElementById(rating + 'Theme');
//         if (rating == websites_rating[website.value]) {
//             themeId.value = default_theme[rating];
//             currentSelect.value = default_theme[rating];
//             currentSelect.style.display = 'inline';
//         }
//         else {
//             currentSelect.style.display = 'none';
//         }
//     }
// }
resetForm();

// -->
</script>
    </td>
  </tr>
</table>

<?php
}
?>